import { baseUrlApi, requestClient, type Result } from '#/api/request';

/** 获取列表 */
export const getModules = (params?: object) => {
  return requestClient.get<Result>(baseUrlApi('/portal/admin/modules'), {
    params,
  });
};

/** 添加 */
export const postModules = (data?: object) => {
  return requestClient.post<Result>(baseUrlApi('/portal/admin/modules'), data);
};

/** 获取信息 */
export const getModulesInfo = (data: { id: number }) => {
  return requestClient.get<Result>(
    baseUrlApi(`/portal/admin/modules/${data.id}`),
  );
};

/** 编辑 */
export const putModules = (data?: any) => {
  return requestClient.put<Result>(
    baseUrlApi(`/portal/admin/modules/${data.id}`),
    data,
  );
};

/** 删除 */
export const deleteModules = (id: number) => {
  return requestClient.delete<Result>(
    baseUrlApi(`/portal/admin/modules/${id}`),
  );
};

/** 设置状态 */
export const postModulesStatus = (data: { id: number; type: string }) => {
  return requestClient.post<Result>(
    baseUrlApi(`/portal/admin/modules/${data.id}/status`),
    data,
  );
};
export const putMoudleSort = (data?: any) => {
  return requestClient.put<Result>(
    baseUrlApi(`/portal/admin/modules/updateSort`),
    data,
  );
};